#include "TableIdent.hpp"


TableIdent::TableIdent()
{
	//this->ids = new vector<string&>;
}


void TableIdent::print() const
{
	for(unsigned int i = 0; i < this->ids.size(); i++)
	{
		cout << i << " : " << this->ids[i] << std::endl;
	}
}

unsigned int TableIdent::add(const string &str)
{
	unsigned int id = 0;
	int ret = getId(str, id);
	if(ret == -1) {
		this->ids.push_back(str);
		id = ids.size() - 1;
	}
	return id;
}

int TableIdent::getId(const string &str, unsigned int &id) const
{
	for(unsigned int i = 0; i < this->ids.size(); i++)
	{
		if(strcmp(str.c_str(),this->ids[i].c_str())==0)
		{
			id = i;
			return 0;
		}
	}
	return -1;

}

const string * TableIdent::getIdent(const unsigned int &id) const
{
	if(id < this->ids.size()) {
		return &this->ids[id];
	}
	return NULL;

}

TableIdent::~TableIdent() {
	/*
	while(!this->ids.empty()) {
		//delete &ids.back();
		ids.pop_back();
	}
	*/
}

